<template>
  <span>
    <div>
      <template v-if="editable && !readonly">
        <a-button size="small" @click="handleCreate"> 创建 </a-button>
      </template>
    </div>

    <a-table
      :columns="columns"
      :data-source="values_display2"
      rowKey="id"
      :customRow="tableCustomRow"
      :pagination="false"
    >
    </a-table>

    <template v-if="fieldInfo.type === 'many2many'"> // </template>

    <template v-else>
      <O2mForm
        ref="subForm"
        :editable="editable"
        :relationInfo="relationInfo"
        :parentViewInfo="parentViewInfo"
        :parentData="parentData"
        @on-commit="handleOnCommit"
      />
    </template>
  </span>
</template>

<script>
import O2mTreeMixin from '@/odooui/O2mTreeMixin'
import O2mForm from './nc_ods_line_ids_form.vue'

export default {
  name: 'FP_O2mTree',
  components: { O2mForm },
  mixins: [O2mTreeMixin],
  props: {},
  data() {
    return {}
  },
  computed: {
    values_display2() {
      // console.log(this.parentData)
      const { record, values } = this.parentData
      const one = { ...record, ...values }
      const total = {
        id: 'total',
        product_name: '合计',
        amount_untaxed: one.amount_untaxed,
        amount_tax: one.amount_tax
      }
      return [...this.values_display, total]
    }
  },

  watch: {},

  created() {},

  mounted() {},

  methods: {
    tableCustomRow(record) {
      return {
        on: {
          // eslint-disable-next-line no-unused-vars
          click: event => {
            // console.log(record)
            if (record.id !== 'total') {
              this.handleOnRowClick(record)
            }
          } // 点击行
        }
      }
    }
  }
}
</script>

<style type="text/css"></style>
